import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import { createI18n } from 'vue-i18n'

import ElementUI from 'element-plus'
import 'element-plus/theme-chalk/index.css'

import enLocale from './locales/lang/en/sys'
import zhLocale from './locales/lang/zh_CN/sys'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

const messages = {
  en: enLocale,
  zh: zhLocale
}
// Create VueI18n instance with options
const i18n = new createI18n({
  locale: 'zh', // set locale
  messages // set locale messages
})

async function bootstrap() {
  const app = createApp(App)

  app.config.globalProperties.$Interface = ''
  app.config.globalProperties.$wss = ''

  app.use(ElementUI)
  // Configure routing
  // 配置路由
  app.use(router)
  // Multilingual configuration
  // 多语言配置
  // Asynchronous case: language files may be obtained from the server side
  // 异步案例：语言文件可能从服务器端获取
  app.use(i18n)

  // 中导入所有图标并进行全局注册
  for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }

  app.mount('#app')
}

bootstrap()
